package cn.xmkeshe.utils.config;

import cn.xmkeshe.utils.interceptor.ValidationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer {

  @Override
  public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(new ValidationInterceptor()).addPathPatterns("/**");
  }

//  如果不注册到spring容器中，则无法取得文件内容
//  @Bean
//  public ValidationInterceptor validationInterceptor(){
//    return new ValidationInterceptor();
//  }
}
